﻿
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;
using System.Xml;

using System.Workflow.Runtime.Hosting;
using System.Workflow.ComponentModel;
using System.Workflow.Activities;

using Antlr.Runtime;
using Antlr.Runtime.Tree;

namespace TextFlow.Engine
{
	internal class TextFlowLoader : WorkflowLoaderService
	{
        protected override Activity CreateInstance( XmlReader workflowDefinitionReader, XmlReader rulesReader )
        {
            workflowDefinitionReader.MoveToContent();

            workflowDefinitionReader.Read();
            workflowDefinitionReader.Read();

            Debug.Assert( workflowDefinitionReader.NodeType == XmlNodeType.CDATA );

            return TextFlowCompiler.Compile( workflowDefinitionReader.Value.Trim() );
        }

        protected override Activity CreateInstance( Type workflowType )
        {
            throw new NotSupportedException();
        }
	}
}
